package study.alex.resumedb.jdo;

import javax.jdo.annotations.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: alex
 * Date: 07.11.13
 * Time: 12:09
 * SVN $Id$
 */


@PersistenceCapable (identityType= IdentityType.APPLICATION, detachable="true")
@Extension(vendorName="DataNucleus", key="mysql-engine-type", value="MyISAM")
public class Contact implements Comparable<Contact> {

    @PrimaryKey
    @Persistent(valueStrategy= IdGeneratorStrategy.INCREMENT, mappedBy = "catalog")
    private Long id;

    private String Name = null;
    private String Address = null;
    private String phones = "";
    private String emails = "";
    private Boolean PersonFlag = true;
    private String Organization = null;
    private String Comment = null;

    public Contact(String name, String address, String organization, String phones, String emails, Boolean personFlag) {
        Name = name;
        Address = address;
        Organization = organization;
        this.phones = phones;
        this.emails = emails;
        PersonFlag = personFlag;
        Comment = "";
    }

    public Contact(String name) {
        this();
        this.Name = name;
    }

    public Contact(Contact aContact) {

        if (aContact != null) {
            this.Name = aContact.Name;
            this.Address = aContact.Address;
            this.PersonFlag = aContact.PersonFlag;
            this.Organization = aContact.Organization;
            this.phones = aContact.phones;
            this.emails = aContact.emails;
            this.Comment = aContact.Comment;
        }
    }

    public Contact() {
        Name = "";
        Address = "";
        PersonFlag = true;
        Organization = "";
        phones = "";
        emails = "";
        Comment = "";
    }

    public String getAddress() {
        return Address;
    }

    public String getOrganization() {
        return Organization;
    }

    public void setOrganization(String organization) {
        Organization = organization;
    }

    public void setAddress(String address) {
        Address = address;
    }

    public String getName() {

        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public void setPersonFlag(Boolean personFlag) {
        PersonFlag = personFlag;
    }

    public Boolean isPerson() {
        return PersonFlag;
    }

    public String getPhones() {
        return phones;
    }

    public String getEmails() {
        return emails;
    }

    public Long getId() {
        return id;
    }

    public String getComment() {
        return Comment;
    }

    public void setComment(String comment) {
        Comment = comment;
    }

    public void setPhones(String phones) {
        this.phones = phones;
    }

    public void setEmails(String emails) {
        this.emails = emails;
    }

    @Override
    public int compareTo(Contact o) {

//        String tmp = Name + " " + Organization;
//        String tmpO = o.Name + " " + o.Organization;
//
//        return tmp.compareTo(tmpO);

        return id.compareTo(o.getId());
    }
}
